package www.bd.com.controller;

import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import www.bd.com.pojo.Article;
import www.bd.com.service.ArticleService;

/**
 * @author Berret
 * @date 2019/4/16 15:21
 * @discription :
 */
@Controller
@CrossOrigin
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping(method = RequestMethod.POST)
    public Result add(@RequestBody Article article){
        articleService.add(article);
        return new Result(true, StatusCode.OK,"操作成功");
    }

    @RequestMapping(value = "/{keywords}/{page}/{size}",method = RequestMethod.POST)
    public Result searchArticle(@PathVariable int page,@PathVariable int  size,@PathVariable String keywords){
        return new Result(true,StatusCode.OK,"查询成功",articleService.searchArticle(page,size,keywords));
    }

}
